﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace websitev2.Controllers
{
    public class TopController : Controller
    {
        //
        // GET: /Top/

        public Models.StartStopEntities db = new Models.StartStopEntities();

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Apps(string ID, string ID2)
        {


            // Load the user. 
            int _numberOfDays = 7;
            if (ID2 != null)
            {

                _numberOfDays = int.Parse(ID2);  
            }
            var user = db.ssUsers.FirstOrDefault(u => u.UserName == ID);
            var items = websitev2.Core.UserCore.ReturnAppUsage(user.UserID, _numberOfDays, 1000);

            #region load the generic user information
            // Load the general information 
            Models.UserGeneralInformationModel oUserGen = new Models.UserGeneralInformationModel();
            oUserGen = websitev2.Core.UserCore.LoadUserGen(user.UserGUID.GetValueOrDefault());
            ViewBag.UserGen = oUserGen;
            ViewBag.MediumAvatar = Core.UserCore.ReturnAvatarURL(user.UserGUID.GetValueOrDefault(), 1);
            #endregion 

            return View(items);
        }

        public ActionResult Time(string ID, string ID2)
        {
            // Load the user. 
            int _numberOfDays = 7;
            if (ID2 != null)
            {

                _numberOfDays = int.Parse(ID2);
            }
            var user = db.ssUsers.FirstOrDefault(u => u.UserName == ID);

            var appUsage = StartStop.Helpers.UsageCore.ReturnAllUsage(user.UserID);

            #region load the generic user information

            // Load the general information 
            Models.UserGeneralInformationModel oUserGen = new Models.UserGeneralInformationModel();
            oUserGen = websitev2.Core.UserCore.LoadUserGen(user.UserGUID.GetValueOrDefault());
            ViewBag.UserGen = oUserGen;
            ViewBag.MediumAvatar = Core.UserCore.ReturnAvatarURL(user.UserGUID.GetValueOrDefault(), 1);

            #endregion 



            return View(appUsage); 
        }

    }
}
